class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int ans = 0;
        if(prices.size() <= 1)
        {
            return ans;
        }
        for(int i = 0; i < prices.size()-1; i++)
        {
            if(prices[i] < prices[i+1])
            {
                ans += prices[i+1]-prices[i];
            }
        }
        return ans;
    }
};
